package ro.sergiu.finder.models.grid;

import java.awt.Color;
import java.io.Serializable;
import ro.sergiu.finder.models.property.AutoresizeMode;
import ro.sergiu.finder.models.property.SelectionMode;

public class GridModel implements Serializable {

    protected SelectionMode selectionMode = SelectionMode.MULTIPLE_INTERVAL_SELECTION;
    protected AutoresizeMode autoresizeMode = AutoresizeMode.AUTO_RESIZE_SUBSEQUENT_COLUMNS;
    protected boolean movableColumns = true;
    protected boolean sortableRecords = true;
    protected Color oddForeground = Color.BLACK;
    protected Color evenForeground = Color.BLACK;
    protected Color oddBackground = Color.WHITE;
    protected Color evenBackground = new Color(-1579033);

    public GridModel(SelectionMode selectionMode, AutoresizeMode autoresizeMode) {
        this.selectionMode = selectionMode;
        this.autoresizeMode = autoresizeMode;
    }

    public GridModel() {
    }

    public SelectionMode getSelectionMode() {
        return selectionMode;
    }

    public void setSelectionMode(SelectionMode selectionMode) {
        this.selectionMode = selectionMode;
    }

    public AutoresizeMode getAutoresizeMode() {
        return autoresizeMode;
    }

    public void setAutoresizeMode(AutoresizeMode autoresizeMode) {
        this.autoresizeMode = autoresizeMode;
    }

    public boolean isMovableColumns() {
        return movableColumns;
    }

    public void setMovableColumns(boolean movableColumns) {
        this.movableColumns = movableColumns;
    }

    public boolean isSortableRecords() {
        return sortableRecords;
    }

    public void setSortableRecords(boolean sortableRecords) {
        this.sortableRecords = sortableRecords;
    }

    public Color getOddForeground() {
        return oddForeground;
    }

    public void setOddForeground(Color oddForeground) {
        this.oddForeground = oddForeground;
    }

    public Color getEvenForeground() {
        return evenForeground;
    }

    public void setEvenForeground(Color evenForeground) {
        this.evenForeground = evenForeground;
    }

    public Color getOddBackground() {
        return oddBackground;
    }

    public void setOddBackground(Color oddBackground) {
        this.oddBackground = oddBackground;
    }

    public Color getEvenBackground() {
        return evenBackground;
    }

    public void setEvenBackground(Color evenBackground) {
        this.evenBackground = evenBackground;
    }

    @Override
    public String toString() {
        return "TableSettings{" + "selectionMode=" + selectionMode + ", autoresizeMode=" + autoresizeMode + ", movableColumns=" + movableColumns + ", sortableRecords=" + sortableRecords + ", oddForeground=" + oddForeground + ", evenForeground=" + evenForeground + ", oddBackground=" + oddBackground + ", evenBackground=" + evenBackground + '}';
    }

    @Override
    public int hashCode() {
        int hash = 3;
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final GridModel other = (GridModel) obj;
        if (this.selectionMode != other.selectionMode) {
            return false;
        }
        if (this.autoresizeMode != other.autoresizeMode) {
            return false;
        }
        if (this.movableColumns != other.movableColumns) {
            return false;
        }
        if (this.sortableRecords != other.sortableRecords) {
            return false;
        }
        if (this.oddForeground != other.oddForeground && (this.oddForeground == null || !this.oddForeground.equals(other.oddForeground))) {
            return false;
        }
        if (this.evenForeground != other.evenForeground && (this.evenForeground == null || !this.evenForeground.equals(other.evenForeground))) {
            return false;
        }
        if (this.oddBackground != other.oddBackground && (this.oddBackground == null || !this.oddBackground.equals(other.oddBackground))) {
            return false;
        }
        if (this.evenBackground != other.evenBackground && (this.evenBackground == null || !this.evenBackground.equals(other.evenBackground))) {
            return false;
        }
        return true;
    }

}
